package com.example.mq.rocketmq.rest;

import com.example.mq.rocketmq.producer.RocketMQProducer;
import com.example.mq.rocketmq.service.OrderServiece;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.CountDownLatch;

/**
 * @author luowj12
 * @since 2021/4/25 16:19
 */

@Slf4j
@RestController
@RequestMapping("mq")
public class RocketMQController {
    @Autowired
    RocketMQProducer rocketMQProducer;

    @Autowired
    OrderServiece orderServiece;

    @PostMapping("/batchSend")
    public void batchSend(){
        for(int i = 0; i < 40; i++) {
            rocketMQProducer.syncSendOrderly(i);
        }
        //int i = 10/0;
    }

    @RequestMapping(value="/send/{id}",method= RequestMethod.GET)
    public void send(@PathVariable("id") Integer id){
        //rocketMQProducer.asyncSend(100);
        rocketMQProducer.syncSendOrderly(id);
        //int i = 10/0;
    }

    @PostMapping("/order")
    public void order(){
        orderServiece.delete("衣服");
        //int i = 10/0;
    }
}
